package com.TanNgee.demo5;


import java.util.concurrent.Future;
import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * @author 陈毅
 * @create 2022/4/26 0:06
 * 主程序类，测试任务类
 */
public class MyTest {
    public static void main(String[] args) {
        //1 创建一个线程池对象
        final ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(3, 5, 1, TimeUnit.MINUTES, new LinkedBlockingDeque<>(15));
        // 2 循环创建任务对象
        for (int i = 0; i < 20; i++) {
            final MyTask myTask = new MyTask("客户" + i);
            final Future<?> submit = threadPoolExecutor.submit(myTask);

        }
        // 3 关闭线程池
        threadPoolExecutor.shutdown();

    }
}
